#pragma once

#include <string>
#include <vector>
#include <map>
using namespace std;

class CmdLineProc
{
private:
	struct Option
	{
		string name;
		string description;
		bool mandatory;
		bool allowMultiple;
		string defaultValue;
	};

	struct Flag
	{
		string name;
		string description;
		bool mandatory;
	};

	vector<Option> mDefinedOptions;
	vector<Flag> mDefinedFlags;

	multimap<string, string> mOptions;
	map<string, bool> mFlags;

	vector<string> mParsedValues;
	string mUsage;

	void LoadCommandString(vector<string> & arguments);

public:
	CmdLineProc();
	void AddOption(const string & name, const string & description, bool mandatory, bool allowMultiple, const string & defaultVal = "");
	void AddFlag(const string & name, const string & description, bool mandatory);
	string & GetUsage();

	void LoadCommandString(const string & cmdLineString);	// throws exception if something is not correct
	void LoadCommandString(int argc, char *const argv[]);	// throws exception if something is not correct 

	string GetValue(const string & name);	// gets first option with this name
	void GetValue(const string & name, vector<string> & options);	// get all options with this name

	bool IsSupplied(const string & name);
	bool GetFlag(const string & name);

	vector<string> & Parse(const string & cmdLine);

};
